import axios from 'axios'

axios.defaults.timeout = 50000

axios.defaults.baseURL = "https://api.yeshaojun.com"
axios.defaults.headers.post['Content-Type'] = 'application/json;'
// axios.defaults.headers.post['Content-Type'] = 'application/json;'

export default {
  $post (url, data, cb) {
    axios.post(url, data, {
      headers: {
        accesstoken: localStorage.getItem('accesstoken')
      }
    }).then(resolve => {
      cb && cb(resolve)
    }, reject => {
      console.log('error:' + reject)
    })
  },
  $get (url, data, cb) {
    axios.get(url, {
      headers: {
        accesstoken: localStorage.getItem('accesstoken')
      },
      params: data
    }).then(resolve => {
      cb && cb(resolve)
    }, reject => {
      console.log('error:' + reject)
    })
  },
  axios
}
